package by.pavlyukevich.paymentsystem.datamodel.user;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import by.pavlyukevich.paymentsystem.datamodel.AbstractEntity;
import by.pavlyukevich.paymentsystem.datamodel.Account;
import by.pavlyukevich.paymentsystem.datamodel.card.Card;

@Entity
public class UserAccount extends AbstractEntity<Integer> {

	@Column(name = "user_type_id")
	@Enumerated(EnumType.ORDINAL)
	@NotNull
	private UserType userType;

	@Column
	@NotNull
	@Size(max = 50)
	private String login;

	@Column
	@NotNull
	@Size(max = 50)
	private String password;

	@ManyToOne(fetch = FetchType.LAZY)
	private Individual individual;

	@ManyToOne(fetch = FetchType.LAZY)
	private Contractor contractor;

	@OneToMany(mappedBy = "userAccount")
	private Set<Card> cards;

	@OneToMany(mappedBy = "userAccount")
	private Set<Account> accounts;

	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Individual getIndividual() {
		return individual;
	}

	public void setIndividual(Individual individual) {
		this.individual = individual;
	}

	public Contractor getContractor() {
		return contractor;
	}

	public void setContractor(Contractor contractor) {
		this.contractor = contractor;
	}

	public Set<Card> getCards() {
		return cards;
	}

	public void setCards(Set<Card> cards) {
		this.cards = cards;
	}

	public Set<Account> getAccounts() {
		return accounts;
	}

	public void setAccounts(Set<Account> accounts) {
		this.accounts = accounts;
	}

}
